#import <Foundation/Foundation.h>
#import <objc/runtime.h>

#import "framework/FWCommon.h"

#import "PIAttendee.h"


@implementation PIAttendee

@synthesize name, status;


// ******************************************************************************************
#pragma mark -
#pragma mark Global sort functions

NSInteger compareAttendees(id attendee1, id attendee2, void *context)
{
    return [((PIAttendee*)attendee1).name caseInsensitiveCompare:((PIAttendee*)attendee2).name];
}


// ******************************************************************************************
#pragma mark -
#pragma mark Initialisation and object management

+ (PIAttendee*)attendeeWithName:(NSString*)newName status:(kPIParticipantStatusType)newStatus
{
    PIAttendee* attendee = [[[PIAttendee alloc] init] autorelease];
    
    attendee->name = [newName copy];
    attendee->status = newStatus;
    
    return attendee;
}

- (void)dealloc
{
    [name release];
    
    [super dealloc];
}


// ******************************************************************************************
#pragma mark -
#pragma mark Debugging functions

- (NSString*)description
{
    return [NSString stringWithFormat:
            @"<%@: %p;"
            " name = %@;"
            " status = %i>",
            [self class],
            self,
            self.name,
            self.status];
}

@end
